<template>
	<view class="container">
		<view class="tabs" @click="onClickTabs">
			<text mark:info="待运输" :class="{active:tabsStatus =='待运输' }">待运输</text>
			<text mark:info="运输中" :class="{active:tabsStatus =='运输中' }">运输中</text>
			<text mark:info="已完成" :class="{active:tabsStatus =='已完成' }">已完成</text>
			<text mark:info="全部订单" :class="{active:tabsStatus =='全部订单' }">全部订单</text>
		</view>
		<view class="body">
			<view class="item gui-margin-top" v-for="(item,index) in orderList" :key="item.id">
				<view class="item-header" v-if="item.status!='待运输'">
					<view class="item-header-first">
						<text>订单编号：{{item.orderNo}}</text>
						
					</view>
					<text>下单时间：{{item.createTime}}</text>
				</view>
				<view class="item-body">

					<view class="item-body-ren">
						<image src="/static/images/Group48097509.png" mode=""></image>
						<view class="ji-user-info">
							<view class="user-info-first">
								<text>{{item.placeOrderName}} {{item.placePhone}}</text>
								<text class="yunsu-box">{{item.status}}</text>
							</view>
							<text>{{item.endAddress}}</text>
						</view>
					</view>
					<view class="item-body-ren">
						<image src="/static/images/Group48097518.png" mode=""></image>
						<view class="ji-user-info">
							<view class="user-info-first">
								<text>{{item.sendingOrderName}} {{item.sendingPhone}}</text>
							</view>
							<text>{{item.startAddress}}</text>
						</view>
					</view>
					<view class="item-body-footer">
						<text class="footer-time">
							预约时间：{{item.selectDate}} {{item.appointmentTime}}
						</text>
						<text>付款方式：{{item.payType}}</text>
					</view>
				</view>
			</view>
			
			<view v-if="orderList.length==0" class="gui-padding gui-margin gui-color-gray gui-text-center">
				暂无订单~
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabsStatus: '待运输',
				type: '',
				orderList: []
			};
		},
		onLoad(e) {
			this.type = e.type
			this.getOrderList(this.type)
		},
		methods: {
			onClickTabs(e) {
				console.log(e.mark.info);
				const status = e.mark.info
				this.tabsStatus = status
				this.getOrderList(this.type)
			},
			// 获取订单详情
			getOrderList(type) {
				let self = this
				uni.gRequest.get('order/orderDetials', {
					status: self.tabsStatus,
					type: type,
				}).then(res => {
					self.orderList = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		width: 100%;
		height: 100%;
		background-color: #fff;
	}

	.container {
		height: 100%;
		border-top: 1rpx #eee solid;
		padding: 0 20rpx;
	}

	.tabs {
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 28rpx;
		color: #989898;
		height: 100rpx;

		text {
			&.active {
				color: #347DFD;
				position: relative;
				line-height: 70rpx;

				&::after {
					content: '';
					display: block;
					position: absolute;
					bottom: 0;
					left: 50%;
					transform: translateX(-50%);
					width: 34rpx;
					height: 6rpx;
					background-color: #347DFD;
					border-radius: 3rpx;
				}
			}
		}
	}

	.body {
		margin: 30rpx 0;
		.item {
			box-shadow: 0rpx 1rpx 20rpx 0rpx rgba(182, 182, 182, 0.15);
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			margin-bottom: 20rpx;

			.item-header {
				margin: 0 30rpx;
				border-bottom: 1rpx #999999 dotted;
				padding: 30rpx 0;
				color: #999999;
				font-size: 26rpx;

				.item-header-first {
					display: flex;
					justify-content: space-between;
					align-items: center;
					margin-bottom: 14rpx;


					.header-yunshuzhong-box {
						padding: 6rpx 8rpx;
						background: #E0EBFF;
						border-radius: 10rpx 0rpx 0rpx 10rpx;
						margin-right: -30rpx;
						margin-top: 20rpx;
						color: #347DFD;
					}
				}
			}

			.item-body {
				padding: 0 30rpx;

				.item-body-ren {
					display: flex;
					align-items: center;
					border-bottom: 1rpx #eee solid;

					image {
						padding-top: 6rpx;
						width: 60rpx;
						height: 70rpx;
					}

					.ji-user-info {
						display: flex;
						flex-direction: column;
						justify-content: center;
						flex: 1;
						font-size: 24rpx;
						color: #999999;
						padding: 36rpx 0;

						.user-info-first {
							display: flex;
							justify-content: space-between;
							align-items: center;
							font-weight: 500;
							font-size: 30rpx;
							color: #000000;
							margin-bottom: 8rpx;

							.yunsu-box {
								background: #FFF4E7;
								font-size: 24rpx;
								color: #FF9213;
								padding: 4rpx 6rpx;
							}
						}
					}
				}

				.item-body-footer {
					font-size: 26rpx;
					color: #000000;
					padding: 20rpx;

					.footer-time {
						display: block;
						margin-bottom: 20rpx;
					}
				}
			}
		}


	}
</style>